<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');  

/**
 * Controller for Companies API.
 * @package api/conrollers
 * @category Controller
 * 
 * @author Mark Angelo Angulo
 * @copyright (c) 2014
 */
class Company_api extends REST_Controller
{
    /*
     * Constructor Method
     */
    public function __construct() {
        parent::__construct();
        
        $this->load->model('company_model');
        
        $this->load->helper('api');
        $this->load->helper('company');
        
        $this->load->library('form_validation');
        
//        $this->image_location = base_url() . 'uploads/images/companies/';
    }
    
    public function index_get()
    {
        $params = get_params();
        $companies = $this->company_model->get_api($params['args'], '*', $params['limit'], $params['offset'], $params['sort'], $params['order']);
        response_companies($companies);
    }
    
    public function index_post()
    {
        $params = post_params();
        $companies = $this->company_model->get_api($params['args']);
        response_companies($companies);
    }
    
    public function index_put()
    {
        $params = $this->put();
        
        echo '<pre>';
        print_r($params); 
        echo '</pre>';
        exit();
    }
    
    public function index_delete()
    {
        $params = $this->delete();
        
        echo '<pre>';
        print_r($params); 
        echo '</pre>';
        exit();
    }
    
    public function search_get()
    {
        $params = get_params(4);
        echo '<pre>';
        print_r($params); 
        echo '</pre>';
        exit();
    }
    
//    /**
//     * Retrieves all clubs using GET method.
//     * @access public
//     */
//    public function all_get()
//    {
//        $param = retrieve_get_values();
//        $args = array('vips_clubs.status' => 'active');
//        $clubs = $this->club_model->and_justice_for_all($args, '*', $param['limit'], $param['offset'], 'date_created', 'desc');
//        response_clubs($clubs);
//    }
//    
//    /**
//     * Retrieves all clubs using POST method.
//     * @access public
//     */
//    public function all_post()
//    {
//        if(valid())
//        {
//            $param = retrieve_post_values();
//            $args = array('vips_clubs.status' => 'active');
//            $clubs = $this->club_model->and_justice_for_all($args, '*', $param['limit'], $param['offset'], 'date_created', 'desc');
//            response_clubs($clubs);
//        }
//    }
//
//     /**
//     * Retrieves clubs by ID using GET method.
//     * @access public
//     */
//    public function by_id_get()
//    {
//        $club_id = retrieve_get_id();
//        $clubs = $this->club_model->and_justice_for_all(array('vips_clubs.id' => $club_id), '*', 1, 0, 'date_created', 'desc');
//        response_clubs($clubs);
//    }
//    
//    /**
//     * Retrieves clubs by ID using POST method.
//     * @access public
//     */
//    public function by_id_post()
//    {
//        $club_id = retrieve_post_id();
//        $clubs = $this->club_model->and_justice_for_all(array('vips_clubs.id' => $club_id), '*', 1, 0, 'date_created', 'desc');
//        response_clubs($clubs);
//    }
//    
//    /**
//     * Retrieves filtered clubs using GET method.
//     * @access public
//     */
//    public function search_get()
//    {
//        $search_term = retrieve_get_search_term();
//        $param = retrieve_get_values();
//        $clubs = $this->club_model->the_more_i_see(array('title'), $search_term, $this->alias, $param['limit'], $param['offset'], 'date_created', 'desc', $this->tables);
//        response_clubs($clubs);
//    }
//    
//    /**
//     * Retrieves filtered clubs using POST method.
//     * @access public
//     */
//    public function search_post()
//    {
//        if(valid())
//        {
//            $search_term = retrieve_post_search_term();
//            $param = retrieve_post_values();
//            $clubs = $this->club_model->the_more_i_see(array('name'), $search_term, '*', $param['limit'], $param['offset'], 'date_created', 'desc');
//            response_clubs($clubs);
//        }
//    }
//    
}

/* End of file companies.php */
/* Location: ./application/modules/api/controllers/companies.php */